package org.kordakus.shoot.gui.renderer;

import java.awt.Component;
import java.io.File;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

import org.kordakus.shoot.gui.ShootGuiUtils;

public class FileNameTableCellRenderer extends JLabel implements TableCellRenderer
{

	private static final long	serialVersionUID	= -4942898572395525595L;

	public FileNameTableCellRenderer()
	{
		this.setOpaque(true);
		this.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
		this.setFont(ShootGuiUtils.FONT_FORM);
	}

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
			int row, int column)
	{
		ShootGuiUtils.setBackgroundColor(this, row, isSelected);
		if (value instanceof String)
		{
			setText(String.valueOf(value));
		} else if (value instanceof File)
		{
			setText(((File) value).getName());
		}
		return this;
	}

}
